//      https://www.nowcoder.com/practice/2820ea076d144b30806e72de5e5d4bbf?tpId=188&tqId=38312&rp=1&ru=%2Factivity%2Foj&qru=%2Fta%2Fjob-code-high-week%2Fquestion-ranking&tab=answerKey






class Solution
{
public:
    int knapsack(int V, int n, vector<vector<int> >& vw)
    {
        vector<int> f(V + 1);
        for (int i = 1; i <= n; i++)
        {
            for (int j = V; j >= vw[i - 1][0]; j--)
            {
                f[j] = max(f[j], f[j - vw[i - 1][0]] + vw[i - 1][1]);
            }
        }
        return f[V];
    }
};